<?php

use yii\helpers\Html;
use kartik\grid\GridView;
use yii\widgets\Pjax;

/* @var $this yii\web\View */
/* @var $searchModel admin\modules\docu\models\DocuSearch */
/* @var $dataProvider yii\data\ActiveDataProvider */

$this->title = Yii::t('app', 'Docus');
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="docu-index">

    <h1><?= Html::encode($this->title) ?></h1>
    <?php Pjax::begin(); ?>
    <?php // echo $this->render('_search', ['model' => $searchModel]); ?>

    <p>
        <?= Html::a(Yii::t('app', 'Create Docu'), ['create'], ['class' => 'btn btn-success']) ?>
    </p>

    <?= GridView::widget([
        'dataProvider' => $dataProvider,
        'filterModel' => $searchModel,
        'columns' => [
            ['class' => 'yii\grid\ActionColumn'],
            [
                'class' => 'kartik\grid\CheckboxColumn',
                'width' => '20px',
            ],
            [
                'class' => 'kartik\grid\SerialColumn',
                'width' => '30px',
            ],
            [
                'class' => '\kartik\grid\DataColumn',
                'attribute' => 'id',
            ],
            [
                'class' => '\kartik\grid\DataColumn',
                'attribute' => 'uuid',
            ],
            [
                'class' => '\kartik\grid\DataColumn',
                'attribute' => 'title',
                'value' => function($model){
                    return \common\components\tools\Html::a($model->title, $model->url, ['target' => "_blank", 'data-pjax' => '0']);
                },
                'format' => 'raw',
            ],
            [
                'class' => \common\components\grid\KEnumColumn::class,
                'enum' => \common\models\db\Docu::getTypes(),
                'attribute' => 'type',
            ],
            [
                'class' => \common\components\grid\KEnumColumn::class,
                'enum' => \common\models\db\Docu::getStatus(),
                'attribute' => 'status',
            ],
            [
                'class' => \kartik\grid\DataColumn::class,
                'attribute' => 'created_at',
                'headerOptions' => [
                    'width' => '215px'
                ],
                'contentOptions' => [
                    'width' => '215px'
                ],
                'format' => ['date', 'php:Y-m-d H:i:s'],
                'filterType' => \kartik\grid\GridView::FILTER_DATE_RANGE,
                'filterWidgetOptions' => [
                    'model' => $searchModel,
                    'attribute' => 'created_at',
                    'presetDropdown' => TRUE,
                    'convertFormat' => true,
                    'pluginOptions' => [
                        'format' => 'Y-m-d',
                        'opens' => 'left',
                        'locale' => [
                            'cancelLabel' => 'Clear',
                            'format' => 'Y-m-d',
                        ],
                    ]
                ],
            ],
            [
                'class' => \kartik\grid\DataColumn::class,
                'attribute' => 'updated_at',
                'headerOptions' => [
                    'width' => '215px'
                ],
                'contentOptions' => [
                    'width' => '215px'
                ],
                'format' => ['date', 'php:Y-m-d H:i:s'],
                'filterType' => \kartik\grid\GridView::FILTER_DATE_RANGE,
                'filterWidgetOptions' => [
                    'model' => $searchModel,
                    'attribute' => 'updated_at',
                    'presetDropdown' => TRUE,
                    'convertFormat' => true,
                    'pluginOptions' => [
                        'format' => 'Y-m-d',
                        'opens' => 'left',
                        'locale' => [
                            'cancelLabel' => 'Clear',
                            'format' => 'Y-m-d',
                        ],
                    ]
                ],
            ],
            [
                'class' => '\kartik\grid\DataColumn',
                'attribute' => 'look_pwd',
                'visible' => $searchModel->canOpt,
            ],
        ],
    ]); ?>
    <?php Pjax::end(); ?>
</div>
